/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;

/**
 *
 * @author edd
 */
@Entity(name = "SalesQuotation")
public class SalesQuotationEntity extends DataObjectEntity implements Serializable {
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date indicativeLeadTime;
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date validity;
    private boolean valid;
    private double totalPrice;
    private Collection<String> serviceRequests = new ArrayList<String>();
    
    @ManyToOne
    private SystemUserEntity systemUser;
    @ManyToOne
    private SalesLeadEntity salesLead;
    @ManyToOne
    private CustomerEntity customer;
    
    @OneToMany (cascade={CascadeType.ALL}, mappedBy="salesQuotation")
    private Collection<ProductQuantityPriceEntity> pqp = new ArrayList<ProductQuantityPriceEntity>();
    
    @OneToMany (cascade={CascadeType.PERSIST}, mappedBy = "salesQuotation")
    private Collection<PurchaseOrderEntity> purchaseOrders = new ArrayList<PurchaseOrderEntity>();    
    
    public SalesQuotationEntity() {
        super();
        setValid(false);
    }

    public SystemUserEntity getSystemUser() {
        return systemUser;
    }

    public void setSystemUser(SystemUserEntity systemUser) {
        this.systemUser = systemUser;
    }

    public SalesLeadEntity getSalesLead() {
        return salesLead;
    }

    public void setSalesLead(SalesLeadEntity salesLead) {
        this.salesLead = salesLead;
    }

    public CustomerEntity getCustomer() {
        return customer;
    }

    public void setCustomer(CustomerEntity customer) {
        this.customer = customer;
    }

    public Collection<PurchaseOrderEntity> getPurchaseOrders() {
        return purchaseOrders;
    }

    public void setPurchaseOrders(Collection<PurchaseOrderEntity> purchaseOrders) {
        this.purchaseOrders = purchaseOrders;
    }

    public Collection<ProductQuantityPriceEntity> getPqp() {
        return pqp;
    }

    public void setPqp(Collection<ProductQuantityPriceEntity> pqp) {
        this.pqp = pqp;
    }

    public Date getIndicativeLeadTime() {
        return indicativeLeadTime;
    }

    public void setIndicativeLeadTime(Date indicativeLeadTime) {
        this.indicativeLeadTime = indicativeLeadTime;
    }

    public Date getValidity() {
        return validity;
    }

    public void setValidity(Date validity) {
        this.validity = validity;
    }

    public boolean isValid() {
        return valid;
    }

    public void setValid(boolean valid) {
        this.valid = valid;
    }

    @Override
    public String childToString() {
        return "SalesQuotationEntity{" + "indicativeLeadTime=" + indicativeLeadTime + ", validity=" + validity + ", valid=" + valid + ", systemUser=" + systemUser + ", salesLead=" + salesLead + ", customer=" + customer + ", pqp=" + pqp + ", purchaseOrders=" + purchaseOrders + '}';
    }

    public double getTotalPrice() {
        return totalPrice;
    }

    public void setTotalPrice(double totalPrice) {
        this.totalPrice = totalPrice;
    }

    public Collection<String> getServiceRequests() {
        return serviceRequests;
    }

    public void setServiceRequests(Collection<String> serviceRequests) {
        this.serviceRequests = serviceRequests;
    }

}
